<template>
  <el-container class="main_con">
    <div class="filter_con ds_block">
      <el-button v-has type="primary" size="medium" @click="addItem">新增自定义表单</el-button>
     </div>
    <div class="list_con">
      <el-table :data="list">
        <el-table-column prop="id" label="表单模板ID"></el-table-column>
        <el-table-column prop="title" label="表单名称"></el-table-column>
        <el-table-column label="操作">
          <template  slot-scope="scope">
            <el-button v-has type="text" @click='EditHandle(scope.row.id)'>编辑</el-button>
            <el-button v-has type="text" @click='DelHandle(scope.row.id)'>删除</el-button>
            <el-button v-has type="text" @click='answerlist(scope.row.id)'>查看</el-button>
          </template>
        </el-table-column>
      </el-table>
      <div class="table_footer" style="justify-content: flex-end;">
        <el-pagination @current-change="ChangeCurrent" class="pages" background layout="prev, pager, next" :total="total">
        </el-pagination>
      </div>
    </div>
  <!--  <el-dialog title="提交记录" :visible.sync="show_answer" width="800px">

    </el-dialog> -->
  </el-container>
</template>

<script>
  import {formtemplatelist,delform} from '@/api/mall/customform'
  // import answer from
  export default{
    data(){
      return{
        page:1,
        size:10,
        list:[],
        total:1
      }
    },
    mounted() {
      this.getlist()
    },
    methods:{
      addItem(){
          this.$router.push('/customform/item');
      },
      getlist(){
        formtemplatelist({},this.page,this.size).then(res=>{
        this.list=res.msg.data
        this.total=res.msg.total
        })
      },
      EditHandle(id){
        this.$router.push({path:'/customform/item',query:{'id':id}});
        // this.$route.push({})
      },
      answerlist(id){
        this.$router.push({path:'/customform/answer',query:{'id':id}});

      },
   
      DelHandle(id){
        let _this = this
        this.$confirm('确认删除？')
          .then(_ => {

            delform(id).then(res => {
              _this.getlist()
            })
          })
          .catch(_ => {});
      },
      //切换页码
      ChangeCurrent(page) {
        this.page = page;
        this.getlist()
      }
    }
  }
</script>

<style></style>
